<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libxlsxwriter: Working with Formats</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libxlsxwriter
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Working with Formats </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#ww_formats_creating">Creating and using a Format object</a></li>
<li class="level1"><a href="#ww_formats_properties">Format methods and Format properties</a></li>
<li class="level1"><a href="#ww_formats_colors">Format Colors</a></li>
<li class="level1"><a href="#ww_formats_default">Format Defaults</a></li>
<li class="level1"><a href="#ww_formats_reusing">Modifying and Reusing Formats</a></li>
<li class="level1"><a href="#ww_formats_categories">Number Format Categories</a></li>
</ul>
</div>
<div class="textblock"><p>The main functions and properties used to add formatting to a cell are shown in <a class="el" href="format_8h.html">The Format object</a>. This section provides some additional information about working with formats.</p>
<h1><a class="anchor" id="ww_formats_creating"></a>
Creating and using a Format object</h1>
<p>Formats are created by calling the <a class="el" href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33" title="Create a new Format object to formats cells in worksheets.">workbook_add_format()</a> method and properties as set using the various functions shown below:</p>
<div class="fragment"><div class="line"><a class="code" href="structlxw__format.html">lxw_format</a> *format = <a class="code" href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33">workbook_add_format</a>(workbook);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="format_8h.html#a85e1b0baf44b445b65894e48722aec14">format_set_bold</a>(format);</div>
<div class="line"><a class="code" href="format_8h.html#a61981b2080bfe6381ede5358ee05b05c">format_set_font_color</a>(format, <a class="code" href="format_8h.html#abeafc6e8222ba9fcfd4f2c2f4e9ea38baedd7412491d9f34fc5f947ada9d196ec">LXW_COLOR_RED</a>);</div>
</div><!-- fragment --><p>Once a Format object has been created and its properties have been set it can be passed as an argument to the <code>worksheet_write*()</code> methods as follows:</p>
<div class="fragment"><div class="line"><a class="code" href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a>(worksheet, 0, 0, <span class="stringliteral">&quot;Hello&quot;</span>, format);</div>
<div class="line"><a class="code" href="worksheet_8h.html#ad9fc47d3beaa2ab4759414e8580c2289">worksheet_write_number</a>(worksheet, 1, 0, 123.456, format);</div>
</div><!-- fragment --><p>Formats can also be passed to the worksheet <code><a class="el" href="worksheet_8h.html#ab9b7fb95e1bd9b0da70befd0d37a9173" title="Set the properties for a row of cells.">worksheet_set_row()</a></code> and <code><a class="el" href="worksheet_8h.html#a9656e4e05d3787eee6b3e4d8e82d9b7f" title="Set the properties for one or more columns of cells.">worksheet_set_column()</a></code> methods to define the default formatting properties for a row or column:</p>
<div class="fragment"><div class="line"><a class="code" href="worksheet_8h.html#ab9b7fb95e1bd9b0da70befd0d37a9173">worksheet_set_row</a>   (worksheet, 2,     format, NULL);</div>
<div class="line"><a class="code" href="worksheet_8h.html#a9656e4e05d3787eee6b3e4d8e82d9b7f">worksheet_set_column</a>(worksheet, 0, 20, format, NULL);</div>
</div><!-- fragment --><h1><a class="anchor" id="ww_formats_properties"></a>
Format methods and Format properties</h1>
<p>The following table shows the Excel format categories and the equivalent <code>libxlsxwriter</code> Format function:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadLeft">Category  </th><th class="markdownTableHeadLeft">Description  </th><th class="markdownTableHeadLeft">Method Name   </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft" rowspan="8"><b>Font</b>  </td><td class="markdownTableBodyLeft">Font type  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a449e2235a9088cc60233ae443acd2b1a" title="Set the font used in the cell.">format_set_font_name()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Font size  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#aec5c1028fa3e25ad60e439fd64afb245" title="Set the size of the font used in the cell.">format_set_font_size()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Font color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a61981b2080bfe6381ede5358ee05b05c" title="Set the color of the font used in the cell.">format_set_font_color()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Bold  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a85e1b0baf44b445b65894e48722aec14" title="Turn on bold for the format font.">format_set_bold()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Italic  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a19cbd7c34692eb7fb35a7411432d836e" title="Turn on italic for the format font.">format_set_italic()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Underline  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#ad35ee5445826bd93ec1bc0d489fc09db" title="Turn on underline for the format:">format_set_underline()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Strikeout  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#ad6e9600723fd772c3cd4d62599beaf31" title="Set the strikeout property of the font.">format_set_font_strikeout()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Super/Subscript  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a471ca432e429505c79982ca5aecd1db0" title="Set the superscript/subscript property of the font.">format_set_font_script()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft"><b>Number</b>  </td><td class="markdownTableBodyLeft">Numeric format  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#af77bbd0003344cb16d455c7fb709e16c" title="Set the number format for a cell.">format_set_num_format()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft" rowspan="2"><b>Protection</b>  </td><td class="markdownTableBodyLeft">Unlock cells  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a1dfd61b72aab2c28c3d51e53e08df587" title="Set the cell unlocked state.">format_set_unlocked()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Hide formulas  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a135d94ec48564c997c5a78ca8b8861e2" title="Hide formulas in a cell.">format_set_hidden()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft" rowspan="6"><b>Alignment</b>  </td><td class="markdownTableBodyLeft">Horizontal align  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a189c83d1f21b01937f1f730720c33d13" title="Set the alignment for data in the cell.">format_set_align()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Vertical align  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a189c83d1f21b01937f1f730720c33d13" title="Set the alignment for data in the cell.">format_set_align()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Rotation  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#ae690004cd77f48646da07796b540c309" title="Set the rotation of the text in a cell.">format_set_rotation()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Text wrap  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a56d55dd9257d8f0645c62b296d2c196d" title="Wrap text in a cell.">format_set_text_wrap()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Indentation  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a99aea699cd7bb3c56a515c9c9e0caa69" title="Set the cell text indentation level.">format_set_indent()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Shrink to fit  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a8fc47dd0e47020358c79e20039cbd760" title="Turn on the text &quot;shrink to fit&quot; for a cell.">format_set_shrink()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft" rowspan="3"><b>Pattern</b>  </td><td class="markdownTableBodyLeft">Cell pattern  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a43ddbc77d637b04fdfbc45e96857d15a" title="Set the background fill pattern for a cell.">format_set_pattern()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Background color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#aeef47436c335daf1801683ac7b3b587d" title="Set the pattern background color for a cell.">format_set_bg_color()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Foreground color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a65086b2b6ee51fd34893e3c53e0578eb" title="Set the pattern foreground color for a cell.">format_set_fg_color()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft" rowspan="10"><b>Border</b>  </td><td class="markdownTableBodyLeft">Cell border  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a9cf7a28a6e8014cb98dff27415e2b1ca" title="Set the cell border style.">format_set_border()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Bottom border  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a05edc61c138b3ba56727efa24592e990" title="Set the cell bottom border style.">format_set_bottom()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Top border  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a39589314f295cf5610a759d233d1e9c5" title="Set the cell top border style.">format_set_top()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Left border  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a21f80d92069d1c0a422daa954c4c6eaa" title="Set the cell left border style.">format_set_left()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Right border  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a4deaaa289159778326c8eb901c70fbb9" title="Set the cell right border style.">format_set_right()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Border color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#ad8fa6d2b638012fc6e331fcd5cf4266b" title="Set the color of the cell border.">format_set_border_color()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Bottom color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a53d5df0f55f154b1019e19f7db3f7df3" title="Set the color of the bottom cell border.">format_set_bottom_color()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Top color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#af1126cbf0f5d4a5832d251572566335e" title="Set the color of the top cell border.">format_set_top_color()</a>   </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft">Left color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a72ae1cd4040cc5d8b6c7b10697fe982a" title="Set the color of the left cell border.">format_set_left_color()</a>   </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft">Right color  </td><td class="markdownTableBodyLeft"><a class="el" href="format_8h.html#a8b1965f2420d7803b6ad5d5b33ce73a9" title="Set the color of the right cell border.">format_set_right_color()</a>   </td></tr>
</table>
<h1><a class="anchor" id="ww_formats_colors"></a>
Format Colors</h1>
<p>Format property colors are specified using a Html style RGB integer value or a limited number of defined colors: </p><div class="fragment"><div class="line"><a class="code" href="format_8h.html#a61981b2080bfe6381ede5358ee05b05c">format_set_font_color</a>(format1, 0x3030E0);</div>
<div class="line"><a class="code" href="format_8h.html#a61981b2080bfe6381ede5358ee05b05c">format_set_font_color</a>(format2, <a class="code" href="format_8h.html#abeafc6e8222ba9fcfd4f2c2f4e9ea38baedd7412491d9f34fc5f947ada9d196ec">LXW_COLOR_RED</a>);</div>
</div><!-- fragment --><p>See see <a class="el" href="working_with_colors.html">Working with Colors</a> for more details.</p>
<h1><a class="anchor" id="ww_formats_default"></a>
Format Defaults</h1>
<p>The default Excel 2007+ cell format is Calibri 11 with all other properties off.</p>
<p>In general a format function call without an argument will turn a property on, for example:</p>
<div class="fragment"><div class="line"><a class="code" href="structlxw__format.html">lxw_format</a> *format = <a class="code" href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33">workbook_add_format</a>(workbook);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="format_8h.html#a85e1b0baf44b445b65894e48722aec14">format_set_bold</a>(format);</div>
</div><!-- fragment --><h1><a class="anchor" id="ww_formats_reusing"></a>
Modifying and Reusing Formats</h1>
<p>Once a format has been created it can be used and reused in <code>worksheet_write*()</code> functions across any number of worksheets:</p>
<div class="fragment"><div class="line"><a class="code" href="structlxw__format.html">lxw_format</a>  *myformat1  = <a class="code" href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33">workbook_add_format</a>(workbook);</div>
<div class="line"><a class="code" href="format_8h.html#a85e1b0baf44b445b65894e48722aec14">format_set_bold</a>(myformat1);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a>(worksheet1, 1, 4, <span class="stringliteral">&quot;Some text&quot;</span>, myformat1);</div>
<div class="line"><a class="code" href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a>(worksheet2, 1, 4, <span class="stringliteral">&quot;Some text&quot;</span>, myformat1);</div>
</div><!-- fragment --><p>However, each unique cell format in an <code>libxlsxwriter</code> spreadsheet must have a corresponding Format object. It isn't possible to use a Format with a <code>worksheet_write*()</code> method and then redefine it for use at a later stage. This is because a Format is applied to a cell not in its current state but in its final state. Consider the following example:</p>
<div class="fragment"><div class="line"><a class="code" href="structlxw__format.html">lxw_format</a> *format = <a class="code" href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33">workbook_add_format</a>(workbook);</div>
<div class="line"><a class="code" href="format_8h.html#a85e1b0baf44b445b65894e48722aec14">format_set_bold</a>(format);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a>(worksheet, 0, 0, <span class="stringliteral">&quot;Hello&quot;</span>, format);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="format_8h.html#a19cbd7c34692eb7fb35a7411432d836e">format_set_italic</a>(format);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a>(worksheet, 1, 0, <span class="stringliteral">&quot;World&quot;</span>, format);</div>
</div><!-- fragment --><p>Cell <code>(0, 0)</code> is assigned a format which with the font set to bold. However, the italic property is subsequently and used in cell <code>(1, 0)</code>. This has the effect of adding italic to any previous uses of <code>format</code>. The result in this case is that "Hello" and "World" will both appear as bold and italic.</p>
<h1><a class="anchor" id="ww_formats_categories"></a>
Number Format Categories</h1>
<p>The <code><a class="el" href="format_8h.html#af77bbd0003344cb16d455c7fb709e16c" title="Set the number format for a cell.">format_set_num_format()</a></code> function shown below, is used to set the number format for numbers used with <code><a class="el" href="worksheet_8h.html#ad9fc47d3beaa2ab4759414e8580c2289" title="Write a number to a worksheet cell.">worksheet_write_number()</a></code>:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;xlsxwriter.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="structlxw__workbook.html">lxw_workbook</a>  *workbook  = <a class="code" href="workbook_8h.html#a1cf96608a23ee4eb0e8467c15240d00b">workbook_new</a>(<span class="stringliteral">&quot;currency_format.xlsx&quot;</span>);</div>
<div class="line">    <a class="code" href="structlxw__worksheet.html">lxw_worksheet</a> *worksheet = <a class="code" href="workbook_8h.html#a81d456b4f65a464e78e4a0030ecc3c2e">workbook_add_worksheet</a>(workbook, NULL);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="structlxw__format.html">lxw_format</a> *currency_format = <a class="code" href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33">workbook_add_format</a>(workbook);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="format_8h.html#af77bbd0003344cb16d455c7fb709e16c">format_set_num_format</a>(currency_format, <span class="stringliteral">&quot;$#,##0.00&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="worksheet_8h.html#ad9fc47d3beaa2ab4759414e8580c2289">worksheet_write_number</a>(worksheet, 0, 0, 1234.56, currency_format);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="workbook_8h.html#ad9e7aeebc0fd43562db5bcd527b2ee5e">workbook_close</a>(workbook);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
</div><!-- fragment --><p>If the number format you use is the same as one of Excel's built in number formats then it will have a number category such as "General", "Number", "Currency", "Accounting", "Date", "Time", "Percentage", "Fraction", "Scientific", "Text", "Special or "Custom". In the case of the example above the formatted output shows up as a Number category:</p>
<div class="image">
<img src="currency_format1.png" alt=""/>
</div>
<p>If we wanted it to have a different category, such as Currency, then we would have to match the number format string with the number format used by Excel. The easiest way to do this is to open the Number Formatting dialog in Excel and set the format that you want:</p>
<div class="image">
<img src="currency_format2.png" alt=""/>
</div>
<p>Then, while still in the dialog, change to Custom. The format displayed is the format used by Excel.</p>
<div class="image">
<img src="currency_format3.png" alt=""/>
</div>
<p>If we put the format that we found (<code>"[$$-409]#,##0.00"</code>) into our previous example and rerun it we will get a number format in the Currency category:</p>
<div class="fragment"><div class="line">include <span class="stringliteral">&quot;xlsxwriter.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="structlxw__workbook.html">lxw_workbook</a>  *workbook  = <a class="code" href="workbook_8h.html#a1cf96608a23ee4eb0e8467c15240d00b">workbook_new</a>(<span class="stringliteral">&quot;currency_format.xlsx&quot;</span>);</div>
<div class="line">    <a class="code" href="structlxw__worksheet.html">lxw_worksheet</a> *worksheet = <a class="code" href="workbook_8h.html#a81d456b4f65a464e78e4a0030ecc3c2e">workbook_add_worksheet</a>(workbook, NULL);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="structlxw__format.html">lxw_format</a> *currency_format = <a class="code" href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33">workbook_add_format</a>(workbook);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="format_8h.html#af77bbd0003344cb16d455c7fb709e16c">format_set_num_format</a>(currency_format, <span class="stringliteral">&quot;[$$-409]#,##0.00&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="worksheet_8h.html#ad9fc47d3beaa2ab4759414e8580c2289">worksheet_write_number</a>(worksheet, 0, 0, 1234.56, currency_format);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="workbook_8h.html#ad9e7aeebc0fd43562db5bcd527b2ee5e">workbook_close</a>(workbook);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
</div><!-- fragment --><p>Here is the output:</p>
<div class="image">
<img src="currency_format4.png" alt=""/>
</div>
<p>The same process can be used to find format strings for "Date" or "Accountancy" formats.</p>
<p>Next: <a class="el" href="working_with_colors.html">Working with Colors</a> </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<div class="ttc" id="aworkbook_8h_html_ad9e7aeebc0fd43562db5bcd527b2ee5e"><div class="ttname"><a href="workbook_8h.html#ad9e7aeebc0fd43562db5bcd527b2ee5e">workbook_close</a></div><div class="ttdeci">lxw_error workbook_close(lxw_workbook *workbook)</div><div class="ttdoc">Close the Workbook object and write the XLSX file.</div></div>
<div class="ttc" id="aformat_8h_html_a19cbd7c34692eb7fb35a7411432d836e"><div class="ttname"><a href="format_8h.html#a19cbd7c34692eb7fb35a7411432d836e">format_set_italic</a></div><div class="ttdeci">void format_set_italic(lxw_format *format)</div><div class="ttdoc">Turn on italic for the format font.</div></div>
<div class="ttc" id="aworkbook_8h_html_a1cf96608a23ee4eb0e8467c15240d00b"><div class="ttname"><a href="workbook_8h.html#a1cf96608a23ee4eb0e8467c15240d00b">workbook_new</a></div><div class="ttdeci">lxw_workbook * workbook_new(const char *filename)</div><div class="ttdoc">Create a new workbook object.</div></div>
<div class="ttc" id="aformat_8h_html_a85e1b0baf44b445b65894e48722aec14"><div class="ttname"><a href="format_8h.html#a85e1b0baf44b445b65894e48722aec14">format_set_bold</a></div><div class="ttdeci">void format_set_bold(lxw_format *format)</div><div class="ttdoc">Turn on bold for the format font.</div></div>
<div class="ttc" id="aformat_8h_html_af77bbd0003344cb16d455c7fb709e16c"><div class="ttname"><a href="format_8h.html#af77bbd0003344cb16d455c7fb709e16c">format_set_num_format</a></div><div class="ttdeci">void format_set_num_format(lxw_format *format, const char *num_format)</div><div class="ttdoc">Set the number format for a cell.</div></div>
<div class="ttc" id="astructlxw__worksheet_html"><div class="ttname"><a href="structlxw__worksheet.html">lxw_worksheet</a></div><div class="ttdoc">Struct to represent an Excel worksheet.</div><div class="ttdef"><b>Definition:</b> worksheet.h:1603</div></div>
<div class="ttc" id="astructlxw__format_html"><div class="ttname"><a href="structlxw__format.html">lxw_format</a></div><div class="ttdoc">Struct to represent the formatting properties of an Excel format.</div><div class="ttdef"><b>Definition:</b> format.h:358</div></div>
<div class="ttc" id="astructlxw__workbook_html"><div class="ttname"><a href="structlxw__workbook.html">lxw_workbook</a></div><div class="ttdoc">Struct to represent an Excel workbook.</div><div class="ttdef"><b>Definition:</b> workbook.h:273</div></div>
<div class="ttc" id="aworksheet_8h_html_ac208046e7a6d12cc87982422efa41b31"><div class="ttname"><a href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a></div><div class="ttdeci">lxw_error worksheet_write_string(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, const char *string, lxw_format *format)</div><div class="ttdoc">Write a string to a worksheet cell.</div></div>
<div class="ttc" id="aformat_8h_html_abeafc6e8222ba9fcfd4f2c2f4e9ea38baedd7412491d9f34fc5f947ada9d196ec"><div class="ttname"><a href="format_8h.html#abeafc6e8222ba9fcfd4f2c2f4e9ea38baedd7412491d9f34fc5f947ada9d196ec">LXW_COLOR_RED</a></div><div class="ttdeci">@ LXW_COLOR_RED</div><div class="ttdef"><b>Definition:</b> format.h:217</div></div>
<div class="ttc" id="aworksheet_8h_html_ab9b7fb95e1bd9b0da70befd0d37a9173"><div class="ttname"><a href="worksheet_8h.html#ab9b7fb95e1bd9b0da70befd0d37a9173">worksheet_set_row</a></div><div class="ttdeci">lxw_error worksheet_set_row(lxw_worksheet *worksheet, lxw_row_t row, double height, lxw_format *format)</div><div class="ttdoc">Set the properties for a row of cells.</div></div>
<div class="ttc" id="aworksheet_8h_html_ad9fc47d3beaa2ab4759414e8580c2289"><div class="ttname"><a href="worksheet_8h.html#ad9fc47d3beaa2ab4759414e8580c2289">worksheet_write_number</a></div><div class="ttdeci">lxw_error worksheet_write_number(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, double number, lxw_format *format)</div><div class="ttdoc">Write a number to a worksheet cell.</div></div>
<div class="ttc" id="aformat_8h_html_a61981b2080bfe6381ede5358ee05b05c"><div class="ttname"><a href="format_8h.html#a61981b2080bfe6381ede5358ee05b05c">format_set_font_color</a></div><div class="ttdeci">void format_set_font_color(lxw_format *format, lxw_color_t color)</div><div class="ttdoc">Set the color of the font used in the cell.</div></div>
<div class="ttc" id="aworksheet_8h_html_a9656e4e05d3787eee6b3e4d8e82d9b7f"><div class="ttname"><a href="worksheet_8h.html#a9656e4e05d3787eee6b3e4d8e82d9b7f">worksheet_set_column</a></div><div class="ttdeci">lxw_error worksheet_set_column(lxw_worksheet *worksheet, lxw_col_t first_col, lxw_col_t last_col, double width, lxw_format *format)</div><div class="ttdoc">Set the properties for one or more columns of cells.</div></div>
<div class="ttc" id="aworkbook_8h_html_a81d456b4f65a464e78e4a0030ecc3c2e"><div class="ttname"><a href="workbook_8h.html#a81d456b4f65a464e78e4a0030ecc3c2e">workbook_add_worksheet</a></div><div class="ttdeci">lxw_worksheet * workbook_add_worksheet(lxw_workbook *workbook, const char *sheetname)</div><div class="ttdoc">Add a new worksheet to a workbook.</div></div>
<div class="ttc" id="aworkbook_8h_html_a279a5d7075d09a3931aae9782afede33"><div class="ttname"><a href="workbook_8h.html#a279a5d7075d09a3931aae9782afede33">workbook_add_format</a></div><div class="ttdeci">lxw_format * workbook_add_format(lxw_workbook *workbook)</div><div class="ttdoc">Create a new Format object to formats cells in worksheets.</div></div>
<!-- HTML footer for doxygen 1.8.20-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Copyright 2014-2020 John McNamara.
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20
</small></address>
</body>
</html>
